{/* LAYOUT模板 */}
	<layout name="layout"/>
{/* LAYOUT模板 */}

{/* import Js,Css */}
	<js href="__PUBLIC__/Js/admin/listTable.js"/>
	<js href="__PUBLIC__/Js/admin/js.util.js"/>
	<css href="__PUBLIC__/Css/admin/common.css"/>
	<js href="__PUBLIC__/Js/admin/js.selectzone.js"/>
	
	<css href="__PUBLIC__/Css/jquery-ui.css" />
	<js href="__PUBLIC__/Js/core/jquery-ui.1.10.4.js" />
	<js href="__PUBLIC__/Js/core/plugins.js"/>
{/* import Js,Css */}

<!-- [position] -->
	<include file="Template:position"/>
<!-- [position] -->

<if condition="$step eq 'user'">
<form name="theForm" action="order.php?act=step_post&step={$step}&order_id={$order_id}&step_act={$step_act}" method="post" onsubmit="return checkUser()">
	<div class="main-div" style="padding: 15px">
		<label>
			<input type="radio" name="anonymous" value="1" checked /> {$lang.anonymous}
		</label><br />
		<label>
			<input type="radio" name="anonymous" value="0" id="user_useridname" /> {$lang.by_useridname}
		</label>
		<input name="keyword" type="text" value="" />
		<input type="button" name="search" value="搜索" onclick="searchUser();" />
		<select name="user"></select>
		<p>{$lang.notice_user}</p>
	</div>
	<div style="text-align:center">
		<p>
			<input name="submit" type="submit"  value="下一个" />
			<input type="button" value="取消"  onclick="location.href='__URL__/process?func=cancel_order&order_id={$order_id}&step_act={$step_act}'" />
		</p>
	</div>
</form>

<elseif condition="$step eq 'goods'"/>
<form name="theForm" action="order.php?act=step_post&step=edit_goods&order_id={$order_id}&step_act={$step_act}" method="post">
	<div class="list-div">
		<table cellpadding="3" cellspacing="1" width="100%">
			<tr>
				<th scope="col">商品名称</th>
				<th scope="col">货号</th>
				<th scope="col">价格</th>
				<th scope="col">数量</th>
				<th scope="col">属性</th>
				<th scope="col">小计</th>
				<th scope="col">操作</th>
			</tr>
			<volist name="goods_list" id="goods">
			<tr>
				<td>
					<if condition="$goods['goods_id'] gt 0 and $goods['extension_code'] neq 'package_buy'">
						<a href="#" onclick="getGoodsInfo({$goods.goods_id});">{$goods.goods_name}</a>
					<elseif condition="$goods['goods_id'] gt 0 and $goods['extension_code'] eq 'package_buy'"/>
						{$goods.goods_name}
					</if>
				</td>
				<td>{$goods.goods_sn}<input name="rec_id[]" type="hidden" value="{$goods.rec_id}" /></td>
				<td>
					<input name="goods_price[]" type="text" style="text-align:right" value="{$goods.goods_price}" size="10" />
					<input name="goods_id[]" type="hidden" style="text-align:right" value="{$goods.goods_id}" size="10" />
				</td>
				<td><input name="goods_number[]" type="text" style="text-align:right" value="{$goods.goods_number}" size="6" /></td>
				<td><textarea name="goods_attr[]" cols="30" rows="{$goods.rows}">{$goods.goods_attr}</textarea></td>
				<td align="right">{$goods.subtotal}</td>
				<td>
					<a href="javascript:confirm_redirect(confirm_drop, 'order.php?act=process&func=drop_order_goods&rec_id={$goods.rec_id}&step_act={$step_act}&order_id={$order_id}')">{$lang.drop}</a>
				</td>
			</tr>
			</volist>
			<tr>
				<td colspan="4">
					<span class="require-field">{$lang.price_note}</span>
				</td>
				<td align="right"><strong>{$lang.label_total}</strong></td>
				<td align="right">{$goods_amount}</td>
				<td>					
					<if condition="$goods">
						<input name="edit_goods" type="submit" value="更新商品" />
					</if>
					<input name="goods_count" type="hidden" value="{$smarty.foreach.goods.total}" />
				</td>
			</tr>
		</table>
	</div>
</form>

<form name="goodsForm" action="order.php?act=step_post&step=add_goods&order_id={$order_id}&step_act={$step_act}" method="post" onsubmit="return addToOrder()">
	<p>
		按商品编号或商品名称或商品货号搜索
		<input type="text" name="keyword" value="" />
		<input type="button" name="search" value="搜索" onclick="searchGoods();" />
		<select name="goodslist" onchange="getGoodsInfo(this.value)"></select>
	</p>
	<div class="list-div">
		<table cellpadding="3" cellspacing="1" width="100%" border="1">
			<tr>
				<th width="100">商品名称</th>
				<td id="goods_name">&nbsp;</td>
			</tr>
			<tr>
				<th>货号</th>
				<td id="goods_sn">&nbsp;</td>
			</tr>
			<tr>
				<th>分类</th>
				<td id="goods_cat">&nbsp;</td>
			</tr>
			<tr>
				<th>品牌</th>
				<td id="goods_brand">&nbsp;</td>
			</tr>
			<tr>
				<th>价格</th>
				<td id="add_price">&nbsp;</td>
			</tr>
			<tr>
				<th>属性<input type="hidden" name="spec_count" value="0" /></th>
				<td id="goods_attr">&nbsp;</td>
			</tr>
			<tr>
				<th>数量</th>
				<td><input name="add_number" type="text" value="1" size="10"></td>
			</tr>
			<tr>
				<td colspan="2" align="center"><input name="add_goods" type="submit" value="加入订单" /></td>
			</tr>
		</table>
	</div>
</form>

<form action="order.php?act=step_post&step=goods&order_id={$order_id}&step_act={$step_act}" method="post" onsubmit="return checkGoods()">
	<p align="center">
		<input name="<if condition="$step eq 'add'">next</else>finish</if>" type="submit" value="<if condition="$step eq 'add'">下一步<else/>确定</if>" />
		<input type="button" value="取消"  onclick="location.href='order.php?act=process&func=cancel_order&order_id={$order_id}&step_act={$step_act}'" />
	</p>
</form>

<elseif condition="$step eq 'consignee'"/>
<form name="theForm" action="__URL__/step_post?step={$step}&order_id={$order_id}&step_act={$step_act}" method="post" onsubmit="return checkConsignee()">
	<div class="list-div">
		<table cellpadding="3" cellspacing="1">
			<tr>
			<th align="left">从已有收货地址中选择：</th>
				<td>
					<select onchange="loadAddress(this.value)">
						<option value="0" selected>请选择地点</option>
						<volist name="address_list" id="address">
							<option value="{$address.address_id}"  <if condition="$Think.get.address_id eq $address.address_id">selected</if> >
								{$address.consignee} {$address.email} {$address.address} {$address.tel}
							</option>
						</volist>
					</select>
				</td>
			</tr>
			<tr>
				<th width="150" align="left">收货人：</th>
				<td>
					<input name="consignee" type="text" value="{$order.consignee}" />
					{$lang.require_field}
				</td>
			</tr>
			<if condition="$exist_real_goods eq 1">
			<tr>
				<th align="left">所在地区：</th>
				<td>
					<select name="country" id="selCountries" onChange="region.changed(this, 1, 'selProvinces')">
						<option value="0" selected="true">{$lang.select_please}</option>
						<volist name="country_list" id="country">
							<option value="{$country.region_id}" <if condition="$order.country eq $country['region_id']">selected</if> >
								{$country.region_name}
							</option>
						</volist>
					</select>
					<select name="province" id="selProvinces" onChange="region.changed(this, 2, 'selCities')">
						<option value="0">{$lang.select_please}</option>
						<volist name="province_list" id="province">
							<option value="{$province.region_id}" <if condition="$order.province eq $province['region_id']">selected</if> >
								{$province.region_name}
							</option>
						</volist>
					</select> 
					<select name="city" id="selCities" onchange="region.changed(this, 3, 'selDistricts')">
						<option value="0">{$lang.select_please}</option>
						<volist name="city_list" id="city">
							<option value="{$city.region_id}" <if condition="$order.city eq $city['region_id']" >selected</if> >
								{$city.region_name}
							</option>
						</volist>
					</select>
					<select name="district" id="selDistricts">
						<option value="0">{$lang.select_please}</option>
						<volist name="district_list" id="district">
							<option value="{$district.region_id}" <if condition="$order.district eq $district['district']">selected</if> >
								{$district.region_name}
							</option>
						</volist>
					</select>
					{$lang.require_field}
				</td>
			</tr>
			</if>
			<tr>
				<th align="left">电子邮件：</th>
				<td>
					<input name="email" type="text" value="{$order.email}" size="40" />
					{$lang.require_field}
				</td>
			</tr>
			<if condition="$exist_real_goods eq 1">
			<tr>
				<th align="left">地址：</th>
				<td>
					<input name="address" type="text" value="{$order.address}" size="40" />
					{$lang.require_field}
				</td>
			</tr>
			<tr>
				<th align="left">邮编：</th>
				<td><input name="zipcode" type="text" value="{$order.zipcode}" /></td>
			</tr>
			</if>
			<tr>
				<th align="left">电话：</th>
				<td>
					<input name="tel" type="text" value="{$order.tel}" />
					{$lang.require_field}
				</td>
			</tr>
			<tr>
				<th align="left">手机：</th>
				<td><input name="mobile" type="text" value="{$order.mobile}" /></td>
			</tr>
			<if condition="$exist_real_goods eq 1">
			<tr>
				<th align="left">标志性建筑：</th>
				<td><input name="sign_building" type="text" value="{$order.sign_building}" size="40" /></td>
			</tr>
			<tr>
				<th align="left">最佳送货时间：</th>
				<td><input name="best_time" type="text" value="{$order.best_time}" size="40" /></td>
			</tr>
			</if>
		</table>
	</div>
	<div align="center">
		<p>
			<if condition="$step_act eq 'add'">
				<input type="button" value="返回上一页" onclick="history.back()" />
			</if>
			<input name="<if condition="$step_act eq 'add'">next<else/>finish</if>" 
				   type="submit" 
				   value="<if condition="$step_act eq 'add'">下一步<else/>确定</if>" />
			<input type="button" value="取消"  onclick="location.href='__URL__/process?func=cancel_order&order_id={$order_id}&step_act={$step_act}'" />
		</p>
	</div>
</form>


<elseif condition="$step eq 'shipping'"/>
<form name="theForm" action="__URL__/step_post?step={$step}&order_id={$order_id}&step_act={$step_act}" method="post" onsubmit="return checkShipping()">
	<div class="list-div">
		<table cellpadding="3" cellspacing="1">
		<tr>
		<th width="5%">&nbsp;</th>
		<th width="25%">{$lang.name}</th>
		<th>{$lang.desc}</th>
		<th width="15%">{$lang.shipping_fee}</th>
		<th width="15%">{$lang.free_money}</th>
		<th width="15%">{$lang.insure}</th>
		</tr>
		<volist name="shipping_list" id="shipping">
		<tr>
		<td>
			<input name="shipping" type="radio" value="{$shipping.shipping_id}" <if condition="$order.shipping_id eq $shipping['shipping_id']">checked</if> onclick="" />
		</td>
		<td>{$shipping.shipping_name}</td>
		<td>{$shipping.shipping_desc}</td>
		<td><div align="right">{$shipping.format_shipping_fee}</div></td>
		<td><div align="right">{$shipping.free_money}</div></td>
		<td><div align="right">{$shipping.insure}</div></td>
		</tr>
		</volist>
		</table>
	</div>
	<p align="right">
		<input name="insure" type="checkbox" value="1" <if condition="$order.insure_fee gt 0">checked</if> /> 我要保价
	</p>
	<p align="center">
		<if condition="$step_act eq 'add'">
			<input type="button" value="上一步"  onclick="history.back()" />
		</if>
		<input name="<if condition="$step_act eq 'add'">next<else/>finish</if>" type="submit" value="<if condition="$step_act eq 'add'">下一步<else/>确定</if>" />
		<input type="button" value="取消" onclick="location.href='order.php?act=process&func=cancel_order&order_id={$order_id}&step_act={$step_act}'" />
	</p>
</form>

<elseif condition="$step eq 'payment'"/>
<form name="theForm" action="__URL__/step_post?step=payment&order_id={$order.order_id}&step_act=edit" method="post" onsubmit="return checkPayment()">
	<div class="list-div">
		<table cellpadding="3" cellspacing="1" width="100%">
			<tr>
				<th width="5%">&nbsp;</th>
				<th width="20%">名称</th>
				<th>描述</th>
				<th width="15%">手续费</th>
			</tr>
			<volist name="payment_list" id="payment">
			<tr>
				<td><input type="radio" name="payment" value="{$payment.pay_id}" <if condition="$order.pay_id eq $payment['pay_id']">checked</if> />
			</td>
				<td>{$payment.pay_name}</td>
				<td>{$payment.pay_desc}</td>
				<td align="right">{$payment.pay_fee}</td>
			</tr>
			</volist>
		</table>
	</div>
	<p align="center">
		<if condition="$step_act eq 'add'">
			<input type="button" value="上一步"  onclick="history.back()" />
		</if>
		<input name="<if condition="$step_act eq 'add'">next<else/>finish</if>" type="submit" value="<if condition="$step_act eq 'add'">下一步<else/>确定</if>" />
		<input type="button" value="取消"  onclick="location.href='__URL__/process?func=cancel_order&order_id={$order_id}&step_act={$step_act}'" />
	</p>
</form>

<elseif condition="$step eq 'other'"/>
<form name="theForm" action="__URL__/step_post?step={$step}&order_id={$order_id}&step_act={$step_act}" method="post">
	<div class="list-div">
		<table cellpadding="3" cellspacing="1" width="100%">
			<tr>
				<th colspan="4" scope="col">选择包装</th>
			</tr>
			<tr>
				<td width="5%" scope="col">&nbsp;</td>
				<td width="35%" scope="col"><div align="center"><strong>名称</strong></div></td>
				<td width="22%" scope="col"><div align="center"><strong>包装费</strong></div></td>
				<td width="22%" scope="col"><div align="center"><strong>免费额度</strong></div></td>
			</tr>
			<tr>
				<td>
					<input type="radio" name="pack" value="0" <if condition="$order['pack_id'] eq 0">checked</if> />
				</td>
				<td>不要包装</td>
				<td>&nbsp;</td>
				<td>&nbsp;</td>
			</tr>
			<volist name="pack_list" id="pack">
				<tr>
					<td>
						<input type="radio" name="pack" value="{$pack.pack_id}" <if condition="$order['pack_id'] eq $pack['pack_id']">checked</if> />
					</td>
					<td>{$pack.pack_name}</td>
					<td><div align="right">{$pack.format_pack_fee}</div></td>
					<td><div align="right">{$pack.format_free_money}</div></td>
				</tr>
			</volist>
			<tr>
				<th colspan="4" scope="col">选择贺卡</th>
			</tr>
			<tr>
				<td scope="col">&nbsp;</td>
				<td scope="col"><div align="center"><strong>名称</strong></div></td>
				<td scope="col"><div align="center"><strong>贺卡费</strong></div></td>
				<td scope="col"><div align="center"><strong>免费额度</strong></div></td>
			</tr>
			<tr>
				<td>
					<input type="radio" name="card" value="0" <if condition="$order['card_id'] eq 0">checked</if> />
				</td>
				<td>不要祝福卡</td>
			</tr>
			<tr>
				<td>&nbsp;</td>
				<td>&nbsp;</td>
			</tr>
			<volist name="card_list" id="card">
				<tr>
					<td>
						<input type="radio" name="card" value="{$card.card_id}" <if condition="$order.card_id eq $card['card_id']">checked</if> />
					</td>
					<td>{$card.card_name}</td>
					<td><div align="right">{$card.format_card_fee}</div></td>
					<td><div align="right">{$card.format_free_money}</div></td>
				</tr>
			</volist>
		</table>
	</div>
	<br />
	<div class="list-div">
		<table cellpadding="3" cellspacing="1">
		<if condition="$exist_real_goods eq 1">
			<tr>
				<th>贺卡祝福语：</th>
				<td><textarea name="card_message" cols="60" rows="3">{$order.card_message}</textarea></td>
			</tr>
			<tr>
				<th>发票类型：</th>
				<td><input name="inv_type" type="text" id="inv_type" value="{$order.inv_type}" size="40" /></td>
			</tr>
			<tr>
				<th>发票抬头：</th>
				<td><input name="inv_payee" value="{$order.inv_payee}" size="40" text="text" /></td>
			</tr>
			<tr>
				<th>发票内容：</th>
				<td><input name="inv_content" value="{$order.inv_content}" size="40" text="text" /></td>
			</tr>
		</if>
			<tr>
				<th>客户给商家的留言：</th>
				<td><textarea name="postscript" cols="60" rows="3">{$order.postscript}</textarea></td>
			</tr>
			<tr>
				<th>缺货处理：</th>
				<td><input name="how_oos" type="text" value="{$order.how_oos}" size="40" /></td>
			</tr>
			<tr>
				<th>商家给客户的留言：</th>
				<td><textarea name="to_buyer" cols="60" rows="3">{$order.to_buyer}</textarea></td>
			</tr>
		</table>
	</div>
	<p align="center">
		<if condition="$step_act eq 'add'">
			<input type="button" value="返回上一页" onclick="history.back()" />
		</if>
		<input name="<if condition="$step_act eq 'add'">next<else/>finish</if>" 
				type="submit" 
				value="<if condition="$step_act eq 'add'">下一个<else/>确定</if>" />
		<input type="button" value="取消"  onclick="location.href='__URL__/process?func=cancel_order&order_id={$order_id}&step_act={$step_act}'" />
	</p>
</form>

<elseif condition="$step eq 'money'"/>
<form name="theForm" action="__URL__/step_post?step={$step}&order_id={$order_id}&step_act={$step_act}" method="post">
	<div class="list-div">
		<table cellpadding="3" cellspacing="1">
			<tr>
				<th width="120">商品总金额：</th>
				<td width="150">{$order.formated_goods_amount}</td>
				<th width="120">折扣：</th>
				<td>
					<input name="discount" type="text" id="discount" value="{$order.discount}" size="15" />
				</td>
			</tr>
			<tr>
				<th>发票税额：</th>
				<td><input name="tax" type="text" id="tax" value="{$order.tax}" size="15" /></td>
				<th>订单总金额：</th>
				<td>{$order.formated_total_fee}</td>
			</tr>
			<tr>
				<th>配送费用：</th>
				<td>
					<if condition="$exist_real_goods">
						<input name="shipping_fee" type="text" value="{$order.shipping_fee}" size="15">
					<else/>
						0
					</if>
				</td>
				<th width="120">已付款金额：</th>
				<td>{$order.formated_money_paid} </td>
			</tr>
			<tr>
				<th>保价费用：</th>
				<td>
					<if condition="$exist_real_goods">
						<input name="insure_fee" type="text" value="{$order.insure_fee}" size="15">
					<else/>
						0
					</if>
				</td>
				<th>使用余额：</th>
				<td>
					<if condition="$order['user_id'] gt 0">
						<input name="surplus" type="text" value="{$order.surplus}" size="15">
					</if>
					{$lang.available_surplus}
					{$available_user_money}
				</td>
			</tr>
			<tr>
				<th>支付费用：</th>
				<td><input name="pay_fee" type="text" value="{$order.pay_fee}" size="15"></td>
				<th>使用积分：</th>
				<td>
					<if condition="$order['user_id'] gt 0">
						<input name="integral" type="text" value="{$order.integral}" size="15">
					</if>
					{$lang.available_integral}
					{$available_pay_points}
				</td>
			</tr>
			<tr>
				<th>包装费用：</th>
				<td>
					<if condition="$exist_real_goods eq 1">
						<input name="pack_fee" type="text" value="{$order.pack_fee}" size="15">
					<else/>
						0
					</if>
				</td>
				<th>使用红包：</th>
				<td>
					<select name="bonus_id">
						<option value="0" <if condition="$order['bonus_id'] eq 0">selected</if> />请选择...</option>
						<volist name="available_bonus" id="bonus">
							<option value="{$bonus.bonus_id}"   
									<if condition="$order['bonus_id'] eq $bonus['bonus_id']">
										selected
									</if> money="{$bonus.type_money}" />{$bonus.type_name} - {$bonus.type_money}</option>
						</volist>
					</select>    
				</td>
			</tr>
			<tr>
				<th>贺卡费用：</th>
				<td>
					<if condition="$exist_real_goods eq 1">
						<input name="card_fee" type="text" value="{$order.card_fee}" size="15">
					<else/>
						0
					</if>
				</td>
				<th>
					<if condition="$order['order_amount'] egt 0">
						{:L('label_money_dues')}
					<else/>
						{:L('label_money_refund')}
					</if>
				</th>
				<td>{$order.formated_order_amount}</td>
			</tr>
		</table>
	</div>
	<p align="center">
		<if condition="$step_act eq 'add'">
			<input type="button" value="上一步"  onclick="history.back()" />
		</if>
		<input name="finish" type="submit"  value="完成" />
		<input type="button" value="取消"  onclick="location.href='__URL__/process?func=cancel_order&order_id={$order_id}&step_act={$step_act}'" />
	</p>
</form>

<elseif condition="$step eq 'invoice'"/>
<form name="theForm" action="order.php?act=step_post&step={$step}&order_id={$order_id}&step_act={$step_act}" method="post" onsubmit="return checkShipping()">
	<div class="list-div">
		<table cellpadding="3" cellspacing="1">
			<tr>
				<th width="5%">&nbsp;</th>
				<th width="25%">{$lang.name}</th>
				<th>{$lang.desc}</th>
			</tr>
			<volist name="shipping_list" id="shipping">
			<tr>
				<td>
					<input name="shipping" type="radio" value="{$shipping.shipping_id}"  <if condition="$order['shipping_id'] eq $shipping['shipping_id']">checked</if> onclick="" />
				</td>
				<td>{$shipping.shipping_name}</td>
				<td>{$shipping.shipping_desc}</td>
			</tr>
			</volist>
			<tr>
				<td colspan="3"><strong>{$lang.shipping_note}</strong></td>
			</tr>
			<tr>
				<td colspan="3">
					<a href="javascript:showNotice('noticeinvoiceno');" title="{$lang.form_notice}">
						<img src="images/notice.gif" width="16" height="16" border="0" alt="{$lang.form_notice}">
					</a>
					<strong>{$lang.label_invoice_no}</strong>
					<input name="invoice_no" type="text" value="{$order.invoice_no}" size="30"/><br/>
					<span class="notice-span" id="noticeinvoiceno" style="display:block;">{$lang.invoice_no_mall}</span>
				</td>
			</tr>
		</table>
	</div>
	<p align="center">
		<if condition="$step_act eq 'add'">
			<input type="button" value="上一步"  onclick="history.back()" />
		</if>
		<input name="<if condition="$step_act eq 'add'">next<else/>finish</if>" type="submit"  value="<if condition="$step_act eq 'add'">{$lang.button_next}<else/>{$lang.button_submit}</if>" />
		<input type="button" value="取消"  onclick="location.href='order.php?act=process&func=cancel_order&order_id={$order_id}&step_act={$step_act}'" />
	</p>
</form>
</if>

<script language="JavaScript">
	var step = '{$step}';
	var orderId = {$order_id};
	var act = '{$smarty.get.act}';
	function checkUser(){
		var eles = document.forms['theForm'].elements;
		/* 如果搜索会员，检查是否找到 */
		if (document.getElementById('user_useridname').checked && eles['user'].options.length == 0){
			alert(pls_search_user);
			return false;
		}
		return true;
	}

	function checkGoods()
	{
		var eles = document.forms['theForm'].elements;

		if (eles['goods_count'].value <= 0)
		{
			alert(pls_search_goods);
			return false;
		}
		return true;
	}

	function checkConsignee()
	{
		var eles = document.forms['theForm'].elements;

		if (eles['country'].value <= 0)
		{
			alert(pls_select_area);
			return false;
		}
		if (eles['province'].options.length > 1 && eles['province'].value <= 0)
		{
			alert(pls_select_area);
			return false;
		}
		if (eles['city'].options.length > 1 && eles['city'].value <= 0)
		{
			alert(pls_select_area);
			return false;
		}
		if (eles['district'].options.length > 1 && eles['district'].value <= 0)
		{
			alert(pls_select_area);
			return false;
		}
		return true;
	}

	function checkShipping()
	{
		if (!radioChecked('shipping'))
		{
			alert(pls_select_shipping);
			return false;
		}
		return true;
	}

	function checkPayment()
	{
		if (!radioChecked('payment'))
		{
			alert(pls_select_payment);
			return false;
		}
		return true;
	}

	/**
	* 返回某 radio 是否被选中一个
	* @param string radioName
	*/
	function radioChecked(radioName)
	{
		var eles = document.forms['theForm'].elements;

		for (var i = 0; i < eles.length; i++)
		{
			if (eles[i].name == radioName && eles[i].checked)
			{
				return true;
			}
		}
		return false;
	}

	/**
	* 按用户编号或用户名搜索用户
	*/
	function searchUser()
	{
		var eles = document.forms['theForm'].elements;

		/* 填充列表 */
		var idName = Utils.trim(eles['keyword'].value);
		if (idName != '')
		{
			Ajax.call('order.php?act=search_users&id_name=' + idName, '', searchUserResponse, 'GET', 'JSON');
		}
	}

	function searchUserResponse(result)
	{
		if (result.message.length > 0)
		{
			alert(result.message);
		}

		if (result.error == 0)
		{
			var eles = document.forms['theForm'].elements;

			/* 清除列表 */
			var selLen = eles['user'].options.length;
			for (var i = selLen - 1; i >= 0; i--)
			{
				eles['user'].options[i] = null;
			}
			var arr = result.userlist;
			var userCnt = arr.length;

			for (var i = 0; i < userCnt; i++)
			{
				var opt = document.createElement('OPTION');
				opt.value = arr[i].user_id;
				opt.text = arr[i].user_name;
				eles['user'].options.add(opt);
			}
		}
	}

	/**
	* 按商品编号或商品名称或商品货号搜索商品
	*/
	function searchGoods()
	{
		var eles = document.forms['goodsForm'].elements;

		/* 填充列表 */
		var keyword = Utils.trim(eles['keyword'].value);
		if (keyword != '')
		{
			Ajax.call('order.php?act=search_goods&keyword=' + keyword, '', searchGoodsResponse, 'GET', 'JSON');
		}
	}

	function searchGoodsResponse(result)
	{
		if (result.message.length > 0)
		{
			alert(result.message);
		}

		if (result.error == 0)
		{
			var eles = document.forms['goodsForm'].elements;

			/* 清除列表 */
			var selLen = eles['goodslist'].options.length;
			for (var i = selLen - 1; i >= 0; i--)
			{
				eles['goodslist'].options[i] = null;
			}

			var arr = result.goodslist;
			var goodsCnt = arr.length;
			if (goodsCnt > 0)
			{
				for (var i = 0; i < goodsCnt; i++)
				{
					var opt = document.createElement('OPTION');
					opt.value = arr[i].goods_id;
					opt.text = arr[i].name;
					eles['goodslist'].options.add(opt);
				}
				getGoodsInfo(arr[0].goods_id);
			}
			else
			{
				getGoodsInfo(0);
			}
		}
	}

	/**
	* 取得某商品信息
	* @param int goodsId 商品id
	*/
	function getGoodsInfo(goodsId)
	{
		if (goodsId > 0)
		{
			Ajax.call('order.php?act=json&func=get_goods_info', 'goods_id=' + goodsId, getGoodsInfoResponse, 'get', 'json');
		}
		else
		{
			document.getElementById('goods_name').innerHTML = '';
			document.getElementById('goods_sn').innerHTML = '';
			document.getElementById('goods_cat').innerHTML = '';
			document.getElementById('goods_brand').innerHTML = '';
			document.getElementById('add_price').innerHTML = '';
			document.getElementById('goods_attr').innerHTML = '';
		}
	}
	function getGoodsInfoResponse(result)
	{
		var eles = document.forms['goodsForm'].elements;

		// 显示商品名称、货号、分类、品牌
		document.getElementById('goods_name').innerHTML = result.goods_name;
		document.getElementById('goods_sn').innerHTML = result.goods_sn;
		document.getElementById('goods_cat').innerHTML = result.cat_name;
		document.getElementById('goods_brand').innerHTML = result.brand_name;

		// 显示价格：包括市场价、本店价（促销价）、会员价
		var priceHtml = '<input type="radio" name="add_price" value="' + result.market_price + '" />市场价 [' + result.market_price + ']<br />' +
		'<input type="radio" name="add_price" value="' + result.goods_price + '" checked />本店价 [' + result.goods_price + ']<br />';
		for (var i = 0; i < result.user_price.length; i++)
		{
			priceHtml += '<input type="radio" name="add_price" value="' + result.user_price[i].user_price + '" />' + result.user_price[i].rank_name + ' [' + result.user_price[i].user_price + ']<br />';
		}
		priceHtml += '<input type="radio" name="add_price" value="user_input" />' + input_price + '<input type="text" name="input_price" value="" /><br />';
		document.getElementById('add_price').innerHTML = priceHtml;

		// 显示属性
		var specCnt = 0; // 规格的数量
		var attrHtml = '';
		var attrType = '';
		var attrTypeArray = '';
		var attrCnt = result.attr_list.length;
		for (i = 0; i < attrCnt; i++)
		{
			var valueCnt = result.attr_list[i].length;

			// 规格
			if (valueCnt > 1)
			{
				attrHtml += result.attr_list[i][0].attr_name + ': ';
				for (var j = 0; j < valueCnt; j++)
				{
					switch (result.attr_list[i][j].attr_type)
					{
						case '0' :
						case '1' :
						attrType = 'radio';
						attrTypeArray = '';
						break;

						case '2' :
						attrType = 'checkbox';
						attrTypeArray = '[]';
						break;
					}
					attrHtml += '<input type="' + attrType + '" name="spec_' + specCnt + attrTypeArray + '" value="' + result.attr_list[i][j].goods_attr_id + '"';
					if (j == 0)
					{
						attrHtml += ' checked';
					}
					attrHtml += ' />' + result.attr_list[i][j].attr_value;
					if (result.attr_list[i][j].attr_price > 0)
					{
						attrHtml += ' [+' + result.attr_list[i][j].attr_price + ']';
					}
					else if (result.attr_list[i][j].attr_price < 0)
					{
						attrHtml += ' [-' + Math.abs(result.attr_list[i][j].attr_price) + ']';
					}
				}
				attrHtml += '<br />';
				specCnt++;
			}
			// 属性
			else
			{
				attrHtml += result.attr_list[i][0].attr_name + ': ' + result.attr_list[i][0].attr_value + '<br />';
			}
		}
		eles['spec_count'].value = specCnt;
		document.getElementById('goods_attr').innerHTML = attrHtml;
	}

	/**
	* 把商品加入订单
	*/
	function addToOrder()
	{
		var eles = document.forms['goodsForm'].elements;

		// 检查是否选择了商品
		if (eles['goodslist'].options.length <= 0)
		{
			alert(pls_search_goods);
			return false;
		}
		return true;
	}

	/**
	* 载入收货地址
	* @param int addressId 收货地址id
	*/
	function loadAddress(addressId)
	{
		location.href += 'order.php?act={$smarty.get.act}&order_id={$smarty.get.order_id}&step={$smarty.get.step}&address_id=' + addressId;
	}
</script>








